package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 房源类型枚举
 * @author hans.zhang
 */
@AllArgsConstructor
@Getter
public enum SourceTypeEnum {
    CZ(1,"社会化长租"),
    GZ(2,"政府公租房"),
    ;

    private Integer value;
    private String name;


    public static Integer getValueByName(String name) {
        SourceTypeEnum sourceTypeEnum = Arrays.stream(SourceTypeEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(sourceTypeEnum != null,"SourceTypeEnum类型:{}不存在",name);
        return sourceTypeEnum.getValue();
    }

    public static String getNameByValue(Integer value) {
        SourceTypeEnum sourceTypeEnum = Arrays.stream(SourceTypeEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(sourceTypeEnum != null,"SourceTypeEnum值:{}不存在",value);
        return sourceTypeEnum.getName();
    }
}
